package cn.com.headfree.mouldshow.dao.impl;

import cn.com.headfree.entity.TEducateInfo;
import cn.com.headfree.mouldshow.dao.TEducateInfoDao;
import cn.com.headfree.vo.simple.EducateInfoVo;
import com.gta.edu.sdk.base.dao.impl.BaseDaoImpl;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository("/tEducateInfoDao")
public class TEducateInfoDaoImpl extends BaseDaoImpl<TEducateInfo> implements TEducateInfoDao {


    @Override
    public List<EducateInfoVo> findByBaseorgId(String deptId) throws Exception{
        Object[] params=new Object[1];
//        StringBuilder sql=new StringBuilder("select t.id,t.erp_no,t.start_time,t.end_time,GET_DIC('PersonnelQualifications',t.educ_name) as educ_name,GET_DIC('AcademicDegree',t.degree_name) as degree_name,t.grad_school,GET_DIC('CollegeCategory',t.school_type) as school_type,t.major,t.acqu_time,u.`NAME` as user_name,t.is_cont_educ,DATE_FORMAT(t.start_time,'%Y-%m-%d %H:%i:%s') as start_time_str,DATE_FORMAT(t.end_time,'%Y-%m-%d %H:%i:%s') as end_time_str,DATE_FORMAT(t.acqu_time,'%Y-%m-%d %H:%i:%s') as acqu_time_str  from t_educate_info t INNER JOIN isc_user u on t.erp_no=u.FAX and u.BASEORG_ID=? WHERE t.is_valid='0' AND t.del_sign='0' ORDER BY t.start_time DESC");
//        StringBuilder sql=new StringBuilder("select t.id,t.erp_no,t.start_time,t.end_time,GET_DIC('PersonnelQualifications',t.educ_name) as educ_name,GET_DIC('AcademicDegree',t.degree_name) as degree_name,t.grad_school,GET_DIC('CollegeCategory',t.school_type) as school_type,t.major,t.acqu_time,u.`NAME` as user_name,t.is_cont_educ,DATE_FORMAT(t.start_time,'%Y-%m-%d %H:%i:%s') as start_time_str,DATE_FORMAT(t.end_time,'%Y-%m-%d %H:%i:%s') as end_time_str,DATE_FORMAT(t.acqu_time,'%Y-%m-%d %H:%i:%s') as acqu_time_str from t_educate_info t INNER JOIN t_dept_emp_rela d on t.erp_no=d.erp_no INNER JOIN (select * from t_org_dept o where o.path like ?) o2 on o2.id=d.dept_id LEFT JOIN isc_user u on t.erp_no=u.FAX WHERE t.is_valid='0' AND t.del_sign='0' ORDER BY t.start_time DESC");
//        StringBuilder sql=new StringBuilder("select t.id,t.erp_no,t.start_time,t.end_time,GET_DIC('PersonnelQualifications',t.educ_name) as educ_name,GET_DIC('AcademicDegree',t.degree_name) as degree_name,t.grad_school,GET_DIC('CollegeCategory',t.school_type) as school_type,t.major,t.acqu_time,u.`NAME` as user_name,t.is_cont_educ from t_educate_info t INNER JOIN t_dept_emp_rela d on t.erp_no=d.erp_no INNER JOIN (select * from t_org_dept o where o.path like ?) o2 on o2.id=d.dept_id LEFT JOIN isc_user u on t.erp_no=u.FAX WHERE t.is_valid='0' AND t.del_sign='0' ORDER BY t.start_time DESC");
        StringBuilder sql=new StringBuilder("select t.id,t.erp_no,t.start_time,t.end_time,t.educ_name,t.degree_name,t.grad_school,t.school_type,t.major,t.acqu_time,u.`NAME` as user_name,t.is_cont_educ from t_educate_info t INNER JOIN t_dept_emp_rela d on t.erp_no=d.erp_no INNER JOIN (select * from t_org_dept o where o.path like ?) o2 on o2.id=d.dept_id LEFT JOIN isc_user u on t.erp_no=u.FAX WHERE t.is_valid='0' AND t.del_sign='0' ORDER BY t.start_time DESC");
        params[0]="%"+deptId+"%";
        return this.findAllBySQL(EducateInfoVo.class,sql.toString(),null,false,params);
    }
}
